package fr.appliClient.client;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.HasWidgets;

import fr.appliClient.client.widget.Main.MainPresenter;
import fr.appliClient.client.widget.Main.MainView;

public class WidgetFactory {

	private EventBus eventBus;

	private MainPresenter mainPresenter;

	public WidgetFactory(EventBus eventBus) {

		this.eventBus = eventBus;
	}

	public MainPresenter getMainPresenter() {

		if (this.mainPresenter == null) {
			this.mainPresenter = new MainPresenter(this.eventBus, new MainView());
		}
		this.mainPresenter.callViewInit();
		return this.mainPresenter;
	}

	/**
	 * Return the center part of mainView
	 * 
	 * @return
	 */
	public HasWidgets getRootContainter() {

		return (HasWidgets) getMainPresenter().getCenter();
	}
}
